local skynet = require "skynet.manager"
local log    = require "bw.log"
local sname  = require "sname"
local env    = require "env"

local function launch_mongo()
    local count = env.MONGO_PER_CONN
    for i = 1, count do
        local db = skynet.newservice "mongod"
        skynet.name("MONGO"..i, db)
    end
end

skynet.start(function()
    log.debug("hello bewater~")

    local wc = skynet.newservice "webclient"
    log.debug(sname.WEBCLIENT)
    skynet.name(sname.WEBCLIENT, wc)

    launch_mongo()

    local monitor = skynet.newservice "monitor"
    skynet.name(sname.MONITOR, monitor)

    local passport = skynet.newservice "passport"
    skynet.name(sname.PASSPORT, passport)

    local http_gate = skynet.newservice "http_gate"
    skynet.name(sname.HTTP_GATE, http_gate)

    local ws_gate = skynet.newservice "ws_gate"
    skynet.name(sname.WS_GATE, ws_gate)

    local hall = skynet.newservice "hall"
    skynet.name(sname.HALL, hall)

    local rank = skynet.newservice "rank"
    skynet.name(sname.RANK, rank)

    local id_producer = skynet.newservice "id_producer"
    skynet.name(sname.ID_PRODUCER, id_producer)
end)
